<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta charset="utf-8" />
    <title><?= $this->users[$this->ownerId]['login'] ?></title>
    <link rel="stylesheet" href="../../css/style.css" />
    <style type="text/css">
        
    </style>
</head>

<body>
    <div id="backTransparent"></div>

    <div id="content">
        <?php
        if (isset($this->noUserPage))
        {
          echo 'Пользователя не существует';
        } else{
        ?>
        <div class="userinfo">
            <div class="photo indent">
                <img src="../../images/camera.gif" alt="Аватар">
            </div>

            <div class="username indent"><?= $this->users[$this->ownerId]['login'] ?>(UserName UserSurname)</div>
            <br>
            <?php
                if (isset($this->pageOwner))
                {
            ?>
            <a href="http://myblog.local/userprofile/logout/">Выход</a>
            <?php
                }
            ?>
        </div>

        <div class="usernotes">
            <span class="header">Заметки</span>
             <?php
                if (isset($this->pageOwner))
                {
             ?>
            <form action="http://myblog.local/note/add/" enctype="application/x-www-form-urlencoded" method="post">
                <textarea id="addNote" rows="5" cols="50" name="noteText">Добавьте новую заметку...</textarea>
                <input class="addButton" type="submit" name="addNote" value="Добавить заметку" >
            </form>
            <?php
                }
            ?>

             <?php
                if (isset($this->noNotes) )
                {
            ?>
                        <hr>
                <div class="note">
                    <span class='emptynotes'>Пользователь еще не оставлял заметок...</span>
                </div>
                    <hr>
            <?php
                }
            ?>

            <?php
            foreach($this->notes as $note)
            {
            ?>
            <hr>
                <div class="note">

                    <div class="photo">
                        <img src="../../images/camera.gif" alt="Аватар" />
                    </div>

                    <div class="notecontent">
                        <span class="username"><?= $this->users[$note['userId']]['login'] ?></span>
                        <span class="noteTime"><?= $note['time'].' '.$note['date'] ?></span>

                        <div class="notetext">
                            <form action="http://myblog.local/note/edit/<?= $note['id'] ?>" method="POST" enctype="application/x-www-form-urlencoded">
                                <textarea disabled="disabled" class="noteText" id="noteText<?= $note['id'] ?>" name="noteText"><?= $note['text'] ?></textarea>
                                <input type="submit" name="editNote" id="note<?= $note['id'] ?>" value="Обновить" style="visibility: hidden;">
                            </form>
                        </div>

                    </div>

                     <div class="notecontrol" style="padding-top: 10px;">
                         <a href="#">Ответить</a><br>
                         <?php
                         if (isset($this->pageOwner))
                         {
                         ?>
                         <a href="http://myblog.local/note/remove/<?= $note['id'] ?>">Удалить</a><br>
                         <a href="#edit" onclick="document.getElementById('note<?= $note['id'] ?>').style.visibility = 'visible';
                                                  document.getElementById('noteText<?= $note['id'] ?>').disabled = false;
                                 ">Редактировать</a>
                         <?php
                         }
                         ?>
                     </div>

                    <form method="post" action="http://myblog.local/comment/add/<?= $note['id'] ?>" style="display:block;float:left;">
                        <textarea rows="5" cols="10" name="commentText"></textarea>
                        <input type="submit" name="addComment" value="Комментировать">
                    </form>
                </div>

            <hr>

                <?php
                    if (isset($this->comments[$note['id']]) )
                    {
                        foreach($this->comments[$note['id']] as $comment)
                        {
                        
                ?>

                                
                <hr>
                <div class="note cIndent">

                    <div class="photo">
                        <img src="../../images/camera.gif" alt="Аватар" />
                    </div>

                    <div class="notecontent">
                        <span class="username"><?= $this->users[$comment['userId']]['login'] ?></span>
                        <span class="noteTime"><?= $comment['time'].' '.$comment['date'] ?></span>

                        <div class="notetext">
                            <form action="http://myblog.local/note/edit/<?= $comment['id'] ?>" method="POST" enctype="application/x-www-form-urlencoded">
                                <textarea disabled="disabled" class="noteText" id="noteText<?= $comment['id'] ?>" name="noteText"><?= $comment['text'] ?></textarea>
                                <input type="submit" name="editNote" id="note<?= $comment['id'] ?>" value="Обновить" style="visibility: hidden;">
                            </form>
                        </div>

                    </div>


                </div>

            <hr>


                <?php
                        }
                    }
                ?>
               
            <?php
                }
        }
            ?>

        </div>
    </div>


</body>
</html>